//给出一个小于六的正整数，输出6*4，不重复三位数，每数间距一空格,末尾无空格
#include<stdio.h>
int main()
{
	int a,i,j,k,g;
	
	scanf("%d",&a);

	g = 0;	
	i = a;
	
	while(i <= a+3){							//用insert键改光标									
		j = a;
		while(j <= a+3){						//从最小向大穷举
			k = a;
			while(k <= a+3){
				if(i != j && i != k && j != k){		//实现不重复
					printf("%d%d%d",i,k,j);
					g++;
					if(g < 6){						//实现6*4+空格+不重复
						printf(" ");
					}
					else{
						printf("\n");
						g = 0;
					}
				}
				k++;
			}
			j++;
		}
		i++;
	}
}
